<template>
    <view>	
        <!-- 导航 -->
        <view class="nav-base bg-white">
            <block v-for="(item, index) in nav_status_list" :key="index">
                <view v-if="nav_status_index == index" class="item fl tc cr-main" :data-index="index" @tap="nav_event">{{item.name}}</view>
                <view v-else class="item fl tc" :data-index="index" @tap="nav_event">{{item.name}}</view>
            </block>
        </view>
		
		<!-- 筛选 -->
		<view>
			<view class="fl" style="padding:6px 0px 10px 10px;">配送:</view>
			<view class="fl"  style="width: 30%;"><uni-datetime-picker  type="date"  v-model="billDate" :clear-icon="false" /></uni-forms-item></view>
			<gx-drop-down-menu v-show="false" ></gx-drop-down-menu>
		</view>
		
        <!-- 订单列表 -->
        <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="60">
            <view v-if="data_list.length > 0" class="padding-horizontal-main padding-top-main">
                <view v-for="(item, index) in data_list" :key="index" class="list-item padding-horizontal-main padding-top-main border-radius-main bg-white oh spacing-mb">
                    <view class="item-base oh br-b padding-bottom-main">
                        <!-- 基础信息 -->
                        <view class="cp" @tap="url_event" :data-value="'/pages/user-order-detail/user-order-detail?id=' + item.id" >
                            <text class="cr-base va-m">
								{{item.warehouse_name}}
							</text>
                        </view>
						<view>下单时间:{{item.create_time}}</view>
                        <text class="fr cr-red">{{item.status_name}}<text v-if="(item.is_under_line_text || null) != null">（{{item.is_under_line_text}}）</text></text>
						
						<view v-if="item.bill_status === '23'">
							<button class="round bg-white cr-green br-green" type="default" size="mini" hover-class="none">已审核</button>
						</view>
						<view v-else>
							<button class="round bg-white cr-green br-green" type="default" size="mini" hover-class="none">未审核</button>
						</view>
                    </view>
                    <view class="br-b-dashed oh padding-vertical-main">
                        <view :data-value="'/pages/user-order-detail/user-order-detail?id=' + item.id" @tap="url_event">
							<view>
								配送:<text>{{item.bill_date}}</text>
							</view>
							<view class="text-size">
								<text>信息:<text class="fw-b">{{item.buy_number_count}}</text>个商品，<text class="sales-price margin-right-xs">￥{{item.total_price}}</text>元</text>
							</view>
                        </view>
                    </view>


                    <view class="item-operation tr br-t padding-vertical-main">
						<button class="round bg-green cr-white br-green" type="default" size="mini" @tap="another_event" :data-value="item.id" :data-index="index" hover-class="none">再来一单</button>
                        <button v-if="item.bill_status == 13 && user.userIdentity == 2" class="round bg-green cr-white br-green" type="default" size="mini" @tap="doApprove_event" :data-value="item.id" :data-index="index" hover-class="none">审核</button>
						<button v-if="item.bill_status == 13" class="round bg-white cr-red br-red" type="default" size="mini" @tap="delete_event" :data-value="item.id" :data-index="index" hover-class="none">删除</button>

						<button v-if="item.bill_status == 23 && user.userIdentity == 2" class="round bg-white cr-red br-red" type="default" size="mini" @tap="doUnApprove_event" :data-value="item.id" :data-index="index" hover-class="none">反审核</button>
                    </view>
                </view>
				


				
            </view>
            <view v-else>
                <!-- 提示信息 -->
                <component-no-data :propStatus="data_list_loding_status"></component-no-data>
            </view>
		

            <!-- 结尾 -->
            <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
			

			
        </scroll-view>



    </view>
</template>
<script>
    const app = getApp();
    import base64 from '../../common/js/lib/base64.js';
    import componentPopup from "../../components/popup/popup";
    import componentNoData from "../../components/no-data/no-data";
    import componentBottomLine from "../../components/bottom-line/bottom-line";

    export default {
        data() {
            return {
				share_info: {},
				billDate:"",
				user: null,
                data_list: [],
                data_total: 0,
                data_page_total: 0,
                data_page: 1,
                data_list_loding_status: 1,
                data_bottom_line_status: false,
                data_is_loading: 0,
                params: null,
                input_keyword_value: '',
                load_status: 0,
                is_show_payment_popup: false,
                payment_list: [],
                payment_id: 0,
                payment_type: '',
                temp_pay_value: '',
                nav_status_list: [
                    { name: "全部订单", value: "-1" },
                    // { name: "待审核", value: "1" },
                    // { name: "已审核", value: "2" },
                    // { name: "已提交供应商", value: "3" },
                ],
                nav_status_index: 0,
                order_select_ids: [],
                // 支付信息
                popup_view_pay_html_is_show: false,
                popup_view_pay_qrcode_is_show: false,
                popup_view_pay_data: null,
                popup_view_pay_timer: null,
                // 基础配置
                home_is_enable_order_bulk_pay: 0
            };
        },

        components: {
            componentPopup,
            componentNoData,
            componentBottomLine
        },
        props: {},

        onLoad(params) {
            // 是否指定状态
            var nav_status_index = 0;
            if ((params.status || null) != null) {
                for (var i in this.nav_status_list) {
                    if (this.nav_status_list[i]['value'] == params.status) {
                        nav_status_index = i;
                        break;
                    }
                }
            }
            this.setData({
                params: params,
                nav_status_index: nav_status_index
            });
			this.getCurrentTime();

        },

        onShow() {
			this.user =app.globalData.get_user_info(this, 'init');
            // 数据加载
            this.init();
            
            // 初始化配置
            this.init_config();
            
            // 分享菜单处理
			this.setData({
			    share_info: {
					title:'订单列表',
			        path: '/pages/user-order/user-order'
			    }
			});
            app.globalData.page_share_handle(this.share_info);
        },

        // 下拉刷新
        onPullDownRefresh() {
            this.setData({
                data_page: 1
            });
            this.get_data_list(1);
        },

        methods: {
			getCurrentTime() {
			      const now = new Date();
			      const year = now.getFullYear();
			      const month = now.getMonth() + 1;
			      const day = now.getDate();
			      const hour = now.getHours();
			      const minute = now.getMinutes();
			      const second = now.getSeconds();
			
			      this.billDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
			},
			toAdd(){
				uni.navigateTo({
				    url: '/pages/user-order/user-order-add'
				});
			},
            // 初始化配置
            init_config(status) {
                if ((status || false) == true) {
                    this.setData({
                        home_is_enable_order_bulk_pay: app.globalData.get_config('config.home_is_enable_order_bulk_pay')
                    });
                } else {
                    app.globalData.is_config(this, 'init_config');
                }
            },

            // 获取数据
            init() {
                if (this.user != false) {
                    // 获取数据
                    this.get_data_list();
                } else {
                    this.setData({
                        data_list_loding_status: 0,
                        data_bottom_line_status: false
                    });
                }
            },

            // 输入框事件
            input_event(e) {
                this.setData({
                    input_keyword_value: e.detail.value
                });
            },

            // 获取数据
            get_data_list(is_mandatory) {
                // 分页是否还有数据
                if ((is_mandatory || 0) == 0) {
                    if (this.data_bottom_line_status == true) {
                        uni.stopPullDownRefresh();
                        return false;
                    }
                }
                
                // 是否加载中
                if(this.data_is_loading == 1) {
                    return false;
                }
                this.setData({
                    data_is_loading: 1,
                    data_list_loding_status: 1
                });
                
                // 加载loding
                uni.showLoading({
                    title: '加载中...'
                });
				console.log("user",this.user)
                
                // 参数
                var order_status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
                console.log("order_status======",order_status);
                // 获取数据
                uni.request({
                    url: app.globalData.get_request_url("indexOrder?pageNo="+this.data_page),
                    method: 'POST',
                    data: {
                        page: this.data_page,
                        keywords: this.input_keyword_value || "",
                        status: order_status,
                        is_more: 1,
						userIdentity: this.user.userIdentity,
						roleId: this.user.role.id,
                    },
					header:{
						'Tenant-Id':this.user.role.tenantId,
						'X-Access-Token':this.user.token,
					},
                    dataType: 'json',
                    success: res => {
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
						console.log("res",res);
                        if (res.data.code == 0) {
                            if (res.data.data.data && res.data.data.data.length > 0) {
                                if (this.data_page <= 1) {
                                    var temp_data_list = res.data.data.data;
                                } else {
                                    var temp_data_list = this.data_list || [];
                                    var temp_data = res.data.data.data;
                                    for (var i in temp_data) {
                                        temp_data_list.push(temp_data[i]);
                                    }
                                }

                                var temp_load_status = this.load_status;
                                this.setData({
                                    payment_list: res.data.data.payment_list || [],
                                    data_list: temp_data_list,
                                    data_total: res.data.data.total,
                                    data_page_total: res.data.data.page_total,
                                    data_list_loding_status: 3,
                                    data_page: this.data_page + 1,
                                    load_status: 1,
                                    data_is_loading: 0
                                });

                                // 下订单支付处理
                                // if (temp_load_status == 0) {
                                //     var ck = app.globalData.data.cache_page_pay_key;
                                //     var pay_data = uni.getStorageSync(ck) || null;
                                //     if (pay_data != null) {
                                //         uni.removeStorageSync(ck);
                                //         this.setData({payment_id: parseInt(pay_data.payment_id || 0)});
                                //         this.pay_handle(pay_data.order_ids);
                                //     }
                                // }

                                // 是否还有数据
                                this.setData({
                                    data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
                                });
                            } else {
                                this.setData({
                                    data_list_loding_status: 0,
                                    data_bottom_line_status: false,
                                    data_list: [],
                                    load_status: 1,
                                    data_is_loading: 0
                                });
                            }
                        } else {
                            this.setData({
                                data_list_loding_status: 0,
                                load_status: 1,
                                data_is_loading: 0
                            });
                            if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
                                app.globalData.showToast(res.data.msg);
                            }
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
                        this.setData({
                            data_list_loding_status: 2,
                            load_status: 1,
                            data_is_loading: 0
                        });
                        app.globalData.showToast('服务器请求出错');
                    }
                });
            },

            // 滚动加载
            scroll_lower(e) {
                this.get_data_list();
            },

            // 支付
            pay_event(e) {
                this.setData({
                    is_show_payment_popup: true,
                    temp_pay_value: e.currentTarget.dataset.value,
                    order_select_ids: []
                });
            },

            // 支付弹窗关闭
            payment_popup_event_close(e) {
                this.setData({
                    is_show_payment_popup: false
                });
            },

            // 支付弹窗发起支付
            popup_payment_event(e) {
                var payment_id = e.currentTarget.dataset.value || 0;
                var payment_type = e.currentTarget.dataset.type || '';
                this.setData({
                    payment_id: payment_id,
                    payment_type: payment_type
                });
                this.payment_popup_event_close();
                this.pay_handle(this.temp_pay_value);
            },

            // 支付方法
            pay_handle(order_ids) {
                // #ifdef H5
                // 微信环境判断是否已有web_openid、不存在则不继续执行跳转到插件进行授权
                if(!app.globalData.is_user_weixin_web_openid(order_ids, this.payment_id)) {
                    return false;
                }
                // #endif

                // 支付方式
                var payment = null;
                for(var i in this.payment_list) {
                    if(this.payment_list[i]['id'] == this.payment_id) {
                        payment = this.payment_list[i];
                    }
                }

                // 请求数据
                var post_data = {
                    ids: order_ids,
                    payment_id: this.payment_id
                };

                // h5自定义重定向地址
                // #ifdef H5
                if(payment != null) {
                    post_data['redirect_url'] = encodeURIComponent(base64.encode(app.globalData.get_page_url(false)+(this.nav_status_index > 0 ? '?status='+this.nav_status_index : '')));
                    // paypal支付方式使用respond_url返回地址、移除重定向地址
                    if(payment.payment == 'PayPal') {
                        post_data['respond_url'] = post_data['redirect_url'];
                        delete post_data['redirect_url'];
                    }
                }
                // #endif

                // 请求支付接口
                uni.showLoading({
                    title: "请求中..."
                });
                uni.request({
                    url: app.globalData.get_request_url("pay", "order"),
                    method: 'POST',
                    data: post_data,
                    dataType: 'json',
                    success: res => {
                        uni.hideLoading();
                        if (res.data.code == 0) {
                            // 是否直接支付成功
                            if ((res.data.data.is_success || 0) == 1) {
                                this.order_item_pay_success_handle(order_ids);
                                app.globalData.showToast('支付成功', 'success');
                            } else {
                                // 支付方式类型
                                switch (res.data.data.is_payment_type) {
                                    // 正常线上支付
                                    case 0:
                                        var data = res.data.data;
                                        // #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
                                        this.common_pay_handle(this, data, order_ids);
                                        // #endif
                                        // #ifdef MP-KUAISHOU
                                        this.kuaishou_pay_handle(this, data, order_ids);
                                        // #endif
                                        // #ifdef MP-QQ
                                        this.qq_pay_handle(this, data, order_ids);
                                        // #endif
                                        // #ifdef H5
                                        this.h5_pay_handle(this, data, order_ids);
                                        // #endif
                                        break;
                                    // 线下支付
                                    case 1:
                                        var order_ids_arr = order_ids.split(',');
                                        var temp_data_list = this.data_list;
                                        for (var i in temp_data_list) {
                                            if (order_ids_arr.indexOf(temp_data_list[i]['id']) != -1) {
                                                temp_data_list[i]['is_under_line'] = 1;
                                            }
                                        }
                                        this.setData({
                                            data_list: temp_data_list
                                        });
                                        app.globalData.alert({
                                            msg: res.data.msg,
                                            is_show_cancel: 0
                                        });
                                        break;
                                    // 钱包支付
                                    case 2:
                                        this.order_item_pay_success_handle(order_ids);
                                        app.globalData.showToast('支付成功', 'success');
                                        break;
                                    // 默认
                                    default:
                                        app.globalData.showToast('支付类型有误');
                                }
                            }
                        } else {
                            // 是否返回html代码展示、则提示错误
                            if(res.data.code == -6666 && (res.data.data || null) != null) {
                                this.setData({
                                    popup_view_pay_data: res.data.data,
                                    popup_view_pay_html_is_show: true
                                });
                            } else {
                                app.globalData.showToast(res.data.msg);
                            }
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        app.globalData.showToast('服务器请求出错');
                    }
                });
            },

            // 快手小程序
            kuaishou_pay_handle(self, data, order_ids) {
                uni.pay({
                    orderInfo: data.data,
                    serviceId: '1',
                    success: res => {                
                        // 数据设置
                        self.order_item_pay_success_handle(order_ids);

                        // 跳转支付页面
                        uni.navigateTo({
                            url: "/pages/paytips/paytips?code=9000"
                        });
                    },
                    fail: res => {
                        app.globalData.showToast('支付失败');
                    }
                });
            },

            // 取消
            cancel_event(e) {
                uni.showModal({
                    title: '温馨提示',
                    content: '取消后不可恢复，确定继续吗?',
                    confirmText: '确认',
                    cancelText: '不了',
                    success: result => {
                        if (result.confirm) {
                            // 参数
                            var id = e.currentTarget.dataset.value;
                            var index = e.currentTarget.dataset.index;
                            
                            // 加载loding
                            uni.showLoading({
                                title: '处理中...'
                            });
                            uni.request({
                                url: app.globalData.get_request_url("cancel", "order"),
                                method: 'POST',
                                data: {
                                    id: id
                                },
                                dataType: 'json',
                                success: res => {
                                    uni.hideLoading();
                                    if (res.data.code == 0) {
                                        var temp_data_list = this.data_list;
                                        temp_data_list[index]['status'] = 5;
                                        temp_data_list[index]['status_name'] = '已取消';
                                        temp_data_list[index]['operate_data']['is_cancel'] = 0;
                                        temp_data_list[index]['operate_data']['is_pay'] = 0;
                                        temp_data_list[index]['operate_data']['is_delete'] = 1;
                                        temp_data_list[index]['is_can_launch_aftersale'] = 0;
                                        this.setData({
                                            data_list: temp_data_list
                                        });
                                        app.globalData.showToast(res.data.msg, 'success');
                                    } else {
                                        app.globalData.showToast(res.data.msg);
                                    }
                                },
                                fail: () => {
                                    uni.hideLoading();
                                    app.globalData.showToast('服务器请求出错');
                                }
                            });
                        }
                    }
                });
            },

            // 收货
            collect_event(e) {
                uni.showModal({
                    title: '温馨提示',
                    content: '请确认已收到货物或已完成，操作后不可恢复，确定继续吗?',
                    confirmText: '确认',
                    cancelText: '不了',
                    success: result => {
                        if (result.confirm) {
                            // 参数
                            var id = e.currentTarget.dataset.value;
                            var index = e.currentTarget.dataset.index;
                            
                            // 加载loding
                            uni.showLoading({
                                title: '处理中...'
                            });
                            uni.request({
                                url: app.globalData.get_request_url("collect", "order"),
                                method: 'POST',
                                data: {
                                    id: id
                                },
                                dataType: 'json',
                                success: res => {
                                    uni.hideLoading();
                                    if (res.data.code == 0) {
                                        var temp_data_list = this.data_list;
                                        temp_data_list[index]['status'] = 4;
                                        temp_data_list[index]['status_name'] = '已完成';
                                        temp_data_list[index]['operate_data']['is_collect'] = 0;
                                        temp_data_list[index]['operate_data']['is_comments'] = 1;
                                        temp_data_list[index]['operate_data']['is_delete'] = 1;
                                        this.setData({
                                            data_list: temp_data_list
                                        });
                                        app.globalData.showToast(res.data.msg, 'success');
                                    } else {
                                        app.globalData.showToast(res.data.msg);
                                    }
                                },
                                fail: () => {
                                    uni.hideLoading();
                                    app.globalData.showToast('服务器请求出错');
                                }
                            });
                        }
                    }
                });
            },
            
			doApprove_event(e){
				uni.showModal({
				    title: '温馨提示',
				    content: '确定审核吗?',
				    confirmText: '确认',
				    cancelText: '不了',
				    success: result => {
				        if (result.confirm) {
				            // 参数
				            var id = e.currentTarget.dataset.value;
				            // 加载loding
				            uni.showLoading({
				                title: '处理中...'
				            });
				            uni.request({
				                url: app.globalData.get_request_url("doApproveOrder"),
				                method: 'POST',
				                data: {
				                    id: id,
									userIdentity: this.user.userIdentity,
									roleId: this.user.role.id,
				                },
								header:{
									'Tenant-Id':this.user.role.tenantId,
									'X-Access-Token':this.user.token,
								},
				                dataType: 'json',
				                success: res => {
				                    uni.hideLoading();
				                    if (res.data.code == 0) {
										this.setData({
										    nav_status_index: -1,
										    data_page: 1,
										    order_select_ids: []
										});
										this.get_data_list(1);
				                        app.globalData.showToast('审核成功。');
				                    } else {
				                        app.globalData.showToast(res.data.msg);
				                    }
				                },
				                fail: () => {
				                    uni.hideLoading();
				                    app.globalData.showToast('服务器请求出错');
				                }
				            });
				        }
				    }
				});
			},
			
			doUnApprove_event(e){
				uni.showModal({
				    title: '温馨提示',
				    content: '确定反审核吗?',
				    confirmText: '确认',
				    cancelText: '不了',
				    success: result => {
				        if (result.confirm) {
				            // 参数
				            var id = e.currentTarget.dataset.value;
				            // 加载loding
				            uni.showLoading({
				                title: '处理中...'
				            });
				            uni.request({
				                url: app.globalData.get_request_url("doUnApproveOrder"),
				                method: 'POST',
				                data: {
				                    id: id,
									userIdentity: this.user.userIdentity,
									roleId: this.user.role.id,
				                },
								header:{
									'Tenant-Id':this.user.role.tenantId,
									'X-Access-Token':this.user.token,
								},
				                dataType: 'json',
				                success: res => {
				                    uni.hideLoading();
				                    if (res.data.code == 0) {
										this.setData({
										    nav_status_index: -1,
										    data_page: 1,
										    order_select_ids: []
										});
										this.get_data_list(1);
				                        app.globalData.showToast('反审核成功。');
				                    } else {
				                        app.globalData.showToast(res.data.msg);
				                    }
				                },
				                fail: () => {
				                    uni.hideLoading();
				                    app.globalData.showToast('服务器请求出错');
				                }
				            });
				        }
				    }
				});
			},
			
			doPushToSupplier_event(e){
				uni.showModal({
				    title: '温馨提示',
				    content: '确定提交给供货商吗?',
				    confirmText: '确认',
				    cancelText: '不了',
				    success: result => {
				        if (result.confirm) {
				            // 参数
				            var id = e.currentTarget.dataset.value;
				            // 加载loding
				            uni.showLoading({
				                title: '处理中...'
				            });
				            uni.request({
				                url: app.globalData.get_request_url("doPushToSupplier"),
				                method: 'POST',
				                data: {
				                    id: id,
									userIdentity: this.user.userIdentity,
									roleId: this.user.role.id,
				                },
								header:{
									'Tenant-Id':this.user.role.tenantId,
									'X-Access-Token':this.user.token,
								},
				                dataType: 'json',
				                success: res => {
				                    uni.hideLoading();
				                    if (res.data.code == 0) {
										this.setData({
										    nav_status_index: -1,
										    data_page: 1,
										    order_select_ids: []
										});
										this.get_data_list(1);
				                        app.globalData.showToast('提交成功。');
				                    } else {
				                        app.globalData.showToast(res.data.msg);
				                    }
				                },
				                fail: () => {
				                    uni.hideLoading();
				                    app.globalData.showToast('服务器请求出错');
				                }
				            });
				        }
				    }
				});
			},
			//再来一单
			another_event(e){
				uni.showModal({
				    title: '温馨提示',
				    content: '确定再来一单吗?',
				    confirmText: '确认',
				    cancelText: '不了',
				    success: result => {
				        if (result.confirm) {
				            // 参数
				            var id = e.currentTarget.dataset.value;
				            var index = e.currentTarget.dataset.index;
				            // 加载loding
				            uni.showLoading({
				                title: '处理中...'
				            });
				            uni.request({
				                url: app.globalData.get_request_url("anotherOrder"),
				                method: 'POST',
				                data: {
				                    id: id,
									userIdentity: this.user.userIdentity,
									roleId: this.user.role.id,
									createBy : this.user.username,
				                },
								header:{
									'Tenant-Id':this.user.role.tenantId,
									'X-Access-Token':this.user.token,
								},
				                dataType: 'json',
				                success: res => {
				                    uni.hideLoading();
				                    if (res.data.code == 0) {
				                        app.globalData.showToast("已成功添加到购物车。", 'success');
				                    } else {
				                        app.globalData.showToast(res.data.msg);
				                    }
				                },
				                fail: () => {
				                    uni.hideLoading();
				                    app.globalData.showToast('服务器请求出错');
				                }
				            });
				        }
				    }
				});
			},
            // 删除
            delete_event(e) {
                uni.showModal({
                    title: '温馨提示',
                    content: '删除后不可恢复，确定继续吗?',
                    confirmText: '确认',
                    cancelText: '不了',
                    success: result => {
                        if (result.confirm) {
                            // 参数
                            var id = e.currentTarget.dataset.value;
                            var index = e.currentTarget.dataset.index;
                            
							console.log("id----",id)
                            // 加载loding
                            uni.showLoading({
                                title: '处理中...'
                            });
                            uni.request({
                                url: app.globalData.get_request_url("deleteOrder"),
                                method: 'POST',
                                data: {
                                    id: id,
									userIdentity: this.user.userIdentity,
									roleId: this.user.role.id,
                                },
								header:{
									'Tenant-Id':this.user.role.tenantId,
									'X-Access-Token':this.user.token,
								},
                                dataType: 'json',
                                success: res => {
                                    uni.hideLoading();
                                    if (res.data.code == 0) {
                                        var temp_data_list = this.data_list;
                                        temp_data_list.splice(index, 1);
                                        var len = temp_data_list.length;
                                        this.setData({
                                            data_list: temp_data_list,
                                            data_list_loding_status: (len == 0) ? 0 : 3,
                                            data_bottom_line_status: (len == 0) ? false : this.data_bottom_line_status,
                                        });
                                        app.globalData.showToast(res.data.msg, '删除成功！');
                                    } else {
                                        app.globalData.showToast(res.data.msg);
                                    }
                                },
                                fail: () => {
                                    uni.hideLoading();
                                    app.globalData.showToast('服务器请求出错');
                                }
                            });
                        }
                    }
                });
            },


            // 导航事件
            nav_event(e) {
                this.setData({
                    nav_status_index: e.currentTarget.dataset.index || 0,
                    data_page: 1,
                    order_select_ids: []
                });
                
                // 重新拉取数据
                this.get_data_list(1);
            },

            // 售后订单事件
            orderaftersale_event(e) {
                var oid = e.currentTarget.dataset.oid || 0;
                var did = e.currentTarget.dataset.did || 0;
                if (oid == 0 || did == 0) {
                    app.globalData.showToast("参数有误");
                    return false;
                }
                
                // 进入售后页面
                uni.navigateTo({
                    url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid + "&did=" + did
                });
            },

            // 订单评论
            comments_event(e) {
                uni.navigateTo({
                    url: "/pages/user-order-comments/user-order-comments?id=" + e.currentTarget.dataset.value
                });
            },

            // 选中处理
            selected_event(e) {
                var oid = e.currentTarget.dataset.oid || 0;
                var temp_select_ids = this.order_select_ids;
                if (temp_select_ids.indexOf(oid) == -1) {
                    temp_select_ids.push(oid);
                } else {
                    for (var i in temp_select_ids) {
                        if (temp_select_ids[i] == oid) {
                            temp_select_ids.splice(i, 1);
                        }
                    }
                }
                this.setData({
                    order_select_ids: temp_select_ids
                });
            },

            // 合并支付
            pay_merge_event(e) {
                this.setData({
                    is_show_payment_popup: true,
                    temp_pay_value: this.order_select_ids.join(',')
                });
            },

            // url事件
            url_event(e) {
                app.globalData.url_event(e);
            },
            
            // 支付二维码展示窗口事件
            popup_view_pay_qrcode_event_close(e) {
                this.setData({
                    popup_view_pay_qrcode_is_show: false
                });
                clearInterval(this.popup_view_pay_timer);
            },
            
            // 支付html展示窗口事件
            popup_view_pay_html_event_close(e) {
                this.setData({
                    popup_view_pay_html_is_show: false
                });
            },
            
            // 页面卸载
            onUnload(e) {
                clearInterval(this.popup_view_pay_timer);
            }
        }
    };
</script>
<style>
    @import './user-order.css';
</style>